//
//  ZH_UserPersonInforTableViewCell.m
//  BuyProvince
//
//  Created by zhangliwen on 2018/7/7.
//  Copyright © 2018年 zhangliwen. All rights reserved.
//

#import "ZH_UserPersonInforTableViewCell.h"
@interface ZH_UserPersonInforTableViewCell()
@property (nonatomic,weak)UILabel *leftLabel;
@property (nonatomic,weak)UILabel *rightLabel;
@property (nonatomic,weak)UIImageView *rightImage;
@property (nonatomic,weak)UISwitch *switchBtn;
@end
@implementation ZH_UserPersonInforTableViewCell

+(instancetype)cellWithTableView:(UITableView*)tableView
{
    static NSString *ID = @"ZH_UserPersonInforTableViewCell";
    ZH_UserPersonInforTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if(cell == nil){
        cell = [[ZH_UserPersonInforTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    return cell;
}
- (void)initDefault{
    [self unShowClickEffect];
//    self.topShortLineImage.hidden = NO;
    self.bottomLongLineImage.hidden = NO;
}
- (void)loadSubviewConstraints{
    [self.rightImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(FITSCALE(16));
        make.centerY.equalTo(self.contentView);
        make.right.equalTo(self.contentView).offset(FITSCALE(-15));
    }];
    [self.leftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.left.equalTo(self.contentView).offset(FITSCALE(17));
    }];
    [self.rightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.right.equalTo(self.contentView).offset(FITSCALE(-45));
    }];
    [self.switchBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.right.equalTo(self.contentView).offset(FITSCALE(-22));
    }];
}
- (void)SiwtchHidden:(BOOL)isHidden{
    self.switchBtn.hidden = isHidden;
}
- (void)setTitleString:(NSString *)titleString{
    self.leftLabel.text = titleString;
}
- (void)setRightString:(NSString *)rightString{
    self.rightLabel.text = rightString;
}
- (void)setHiddenRightImage:(BOOL)isbool{
    self.rightImage.hidden = isbool;
}
- (void)setHiddenRightLabel:(BOOL)isbool{
    self.rightLabel.hidden = isbool;
}
- (void)action:(UISwitch *)sender{
    UISwitch *switchButton = (UISwitch*)sender;
    BOOL isButtonOn = [switchButton isOn];
//    if (self.onEnterSwitchBlock) {
//        self.onEnterSwitchBlock(isButtonOn);
//    }
}
- (void)updataUI:(NSInteger)index dic:(NSDictionary *)data{
    if (data) {
        if (index == 0) {
            self.rightLabel.text = [NSString stringWithFormat:@"%@",data[@"phone"]];
        }
        if (index == 1) {
            self.rightLabel.text = [NSString stringWithFormat:@"%@",data[@"wx"]];
        }
        else if (index == 2){
            self.rightLabel.text = [NSString stringWithFormat:@"%@",data[@"qq"]];
        }
//        else if (index == 3){
//            if (![data[@"ali_account"] isKindOfClass:[NSNull class]]) {
//                self.rightLabel.text = data[@"ali_account"];
//            }
//
//        }
//        else if (index == 4){
//            if (![data[@"w_nickname"] isKindOfClass:[NSNull class]]) {
//                self.rightLabel.text = data[@"w_nickname"];
//            }
//        }
//        else if (index == 5){
//            if (![data[@"phone"] isKindOfClass:[NSNull class]]) {
//                self.rightLabel.text = data[@"phone"];
//            }
//        }
    }
}
#pragma mark - getter,setter
- (UILabel *)leftLabel{
    if (!_leftLabel) {
        UILabel *label = [UILabel createLabelWithText:@"" font:kFontSize_28];
        [self.contentView addSubview:_leftLabel = label];
    }
    return _leftLabel;
}
- (UIImageView *)rightImage{
    if (!_rightImage) {
        UIImageView *image = [UIImageView createImageViewWithName:@"icon_mygetmore1"];
        [self.contentView addSubview:_rightImage = image];
    }
    return _rightImage;
}
- (UILabel *)rightLabel{
    if (!_rightLabel) {
        UILabel *label = [UILabel createLabelWithText:@"" font:kFontSize_28];
        label.textColor = [UIColor colorWithHexString:@"#333333"];
        label.textAlignment = NSTextAlignmentRight;
        [self.contentView addSubview:_rightLabel = label];
    }
    return _rightLabel;
}
- (UISwitch *)switchBtn{
    if (!_switchBtn) {
        UISwitch *switchs = [UISwitch createSwitchButtonWithTintColor:[UIColor colorWithHexString:@"#00E266"] target:self action:@selector(action:)];
        switchs.hidden = YES;
        [self.contentView addSubview:_switchBtn = switchs];
    }
    return _switchBtn;
}
@end
